//
//  FormView.h
//  etionUI
//
//  Created by wangjian on 12/23/13.
//  Copyright (c) 2013 GuangZhouXuanWu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FormCellView.h"

#define FORMVIEW_DEF_ROW_H 46
#define FORMVIEW_DEF_COL_W 46

@class CFormView;
@protocol CFormViewDelegate <UIScrollViewDelegate>

- (NSUInteger)numberOfRowsWithFormView:(CFormView *)view;
- (NSUInteger)numberOfColsWithFormView:(CFormView *)view;
- (CFormCellView *)formView:(CFormView *)view cellAtIndex:(CFormCellIndex *)index;
- (void)formView:(CFormView *)view didClickCellAtIndex:(CFormCellIndex *)index;

@optional
- (CGFloat)formView:(CFormView *)view heightForRow:(NSUInteger)row;
- (CGFloat)formView:(CFormView *)view widthForCol:(NSUInteger)col;

@end

@interface CFormView : UIScrollView

@property (nonatomic, assign) id<CFormViewDelegate> delegate;

@property (nonatomic, assign) NSUInteger rowNumber;         //记录行数
@property (nonatomic, assign) NSUInteger colNumber;         //记录列数
@property (nonatomic, retain) CFormCellIndex *curSelectedIndex;

- (void)reload;
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;

- (CFormCellView *)cellAtIndex:(CFormCellIndex *)index;
- (CFormCellIndex *)indexForCell:(CFormCellView *)cell;
- (CGRect)frameOfCellAtIndex:(CFormCellIndex *)index;

- (void)scrollToIndex:(CFormCellIndex *)index animated:(BOOL)animated;

- (CGFloat)heightForRow:(NSUInteger)row;
- (CGFloat)widthForCol:(NSUInteger)col;
- (void)setHeight:(CGFloat)height forRow:(NSUInteger)row animated:(BOOL)animated;
- (void)setWidth:(CGFloat)width forCol:(NSUInteger)col animated:(BOOL)animated;

@end

